#ifndef _DTEXTSCANNABLE_H
#define _DTEXTSCANNABLE_H

//==============================================================================
//
//         DTextScannable - the text scannable protocol in the ofc-library
//
//               Copyright (C) 2004  Dick van Oudheusden
//  
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free
// Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//==============================================================================
// 
//  $Date: 2005-10-21 18:45:20 $ $Revision: 1.2 $
//
//==============================================================================

#include "ofc/config.h"

@class DText;

//
// The DTextScannable protocol extends a Readable protocol. It specifies the 
// interface for higher level methods for scanning of text by a class 
// implementing this interface. Due to the 'forward' looking nature of some of 
// the methods, not all classes implementing the Readable interfaces are able
// to implement the DTextScannable interface.
//

@protocol DTextScannable

//
// Scan for a text string until a separator character. The separator character is 
// is not part of the returned string and is skipped in the Readable.
//
// @return a (new) text string (or nil if the separator is not found)
//

- (DText *) scanText :(char) separator;

//
// Scan for a text string until one of the separator characters in the 
// separator string.  The matched separator character is is not part of 
// the returned string, is skipped in the text object and is returned in 
// the separator argument.
//
// @param separators  the c-string with the separators
// @param separator   the destination for the actual matched separator character (or NULL)
//
// @return a (new) text string (or nil if none of the separators is found)
//

- (DText *) scanText :(const char *) separators :(char *) separator;

//
// Match a string case sensitive; if the string matched, the current position in
// the readable is moved to the location after the matched string.
//
// @param cstring   the c-string to be matched
//
// @return does the string match ?
//

- (BOOL) cmatch :(const char *) cstr;

//
// Match a string case insensitive; if the string matched, the current position in
// the readable is moved to the location after the matched string.
//
// @param cstring   the c-string to be matched
//
// @return does the string match ?
//

- (BOOL) imatch :(const char *) cstr;

//
// Scan for an integer value
//
// @param wrong   the value returned if there is no int to scan
//
// @return the integer read (or the wrong value)
//

- (int) scanInt :(int) wrong;

//
// Skip characters
//
// @param ch    the character to be skipped
//
// @return the number of characters skipped
//

- (int) skipChar :(char) ch;

//
// Skip whitespace
//
// @return the number of characters skipped
//

- (int) skipWhiteSpace;

@end

#endif

/*============================================================================*/

